from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from rest_framework.routers import DefaultRouter
from . import views
from .v3 import views as views3
from django.urls import path, include
from django.views.static import serve
from rest_framework.routers import DefaultRouter
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

app_name = 'jewelry'  # 定义应用命名空间

# urls.py 中确保注册所有视图集
router = DefaultRouter()
router.register(r'products', views.ProductViewSet, basename='product')
router.register(r'banners', views.BannerViewSet, basename='banners')  # 轮播图
router.register(r'special-offers', views.SpecialOfferViewSet, basename='special_offer')  # 特价商品
router.register(r'categories', views.CategoryViewSet, basename='category')  # 分类
router.register(r'orders', views.OrdersViewSet, basename='orders')  # 订单查询

# router.register('users', views.UserViewSet, basename='user')      # 用户管理
# router.register('groups', views.GroupViewSet, basename='group')   # 组(角色)管理

urlpatterns = [
    path('login/', views.LoginView.as_view(), name='login_v'),  # 用头像和昵称登录
    path('login_2/', views.WeChatLoginView.as_view(), name='login_v2'),  # 用手机号登录
    path('categories/<int:pk>/', views.CategoryDetailAPI.as_view(), name='category-detail'),  # 从分类找商品
    path('paymentV3/', views3.PaymentV3View.as_view(), name='paymentV3'),  # 支付环节(V3版本, 测试)
    path('paymentV3/callback/', views3.PaymentCallbackView.as_view(), name='paymentV3_callback'),  # 支付返回通知(V3版本, 测试)
    path('orders/status/', views3.OrderStatusView.as_view(), name='order-status'),  # 订单状态查询

    path('logistics/', views.LogisticsTrackView.as_view(), name='logistic'),  # 物流信息查询

    path('avatNickName/', views.AvatNickNameAPIView.as_view(), name='avatNickName'),

    # path('users_view/', views.users_view, name='users_view'),  # 用户管理测试
    # # 仪表盘路由
    # path('dashboard/', views.DashboardView.as_view(), name='dashboard'),
    #
    # path('auth/', include([   # 权限管理
    #     path('login/', TokenObtainPairView.as_view()),
    #     path('refresh/', TokenRefreshView.as_view()),
    # ])),

    path('', include(router.urls)),

]


